const express=require('express');
const router=express.Router();
const db=require('../utils/db')

router.get('/sealapplyget',(req,res)=>{
    const {page,count,search}=req.query;
    const sql=`select * from s_sealapply  limit ${(page-1)*count},${count};`;
    const sql2=`select count(*) as total from s_sealapply where number like '%${search}%';`
    db.query(sql,(err,data)=>{
        if(err){
            console.log(data);
            res.json({error:1,msg:err});
        }else{
            db.query(sql2,(err2,data2)=>{
                if(err2){
                    res.json({error:1,msg:err2});
                }else{
                    console.log(data2)
                    res.json({error:0,data:data,total:data2[0].total});
                }
            })
        }
    })
})

module.exports=router;